package models

import (
	__ "ew-srv/basic/proto"
	"gorm.io/gorm"
)

type Eclass struct {
	gorm.Model
	Title     string  `gorm:"type:varchar(20);not null;comment:'课程标题'"`
	Image     string  `gorm:"type:varchar(290);not null;comment:'课程封面'"`
	Url       string  `gorm:"type:varchar(290);not null;comment:'视频播放地址'"`
	Price     float64 `gorm:"type:decimal(10,2);not null;comment:'普通价格'"`
	MePrice   float64 `gorm:"type:decimal(10,2);not null;comment:'会员价格'"`
	ClassPage int     `gorm:"type:int;comment:'课程章节'"`
}

func (e *Eclass) CreateC(db *gorm.DB) error {
	err := db.Create(&e).Error
	return err
}

func (e *Eclass) Geteclass(db *gorm.DB, id int) error {
	err := db.Model(&Eclass{}).Where("id = ?", id).Find(&e).Error
	return err
}

func (e *Eclass) GeteclassList(db *gorm.DB) (List []*__.EClassList, err error) {
	err = db.Model(&Eclass{}).Find(&List).Error
	return
}
